
import br.com.sigeden.model.Denuncia;
import br.com.sigeden.util.HibernateUtil;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author David Amom <davidamom@gmail.com>
 */
public class Teste {

    public static void main(String[] args) {
        Session sessao = null;
        Transaction transacao;
        Denuncia denuncia = new Denuncia();
        denuncia.setId(1L);
        try {
            sessao = HibernateUtil.getSessionFactory().openSession();
            transacao = sessao.beginTransaction();

            Query query = sessao.createQuery("UPDATE Denuncia SET afirmacoes = afirmacoes + 1 WHERE id = :id");
            query.setParameter("id", denuncia.getId());
            query.executeUpdate();

            transacao.commit();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            sessao.close();
        }
    }
}
